<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Gets a collection</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongocollection.findone.html">« MongoCollection::findOne</a></li>
      <li style="float: right;"><a href="mongocollection.getdbref.html">MongoCollection::getDBRef »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongocollection.html">MongoCollection</a></li>
    <li>Gets a collection</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongocollection.get" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoCollection::__get</h1>
  <p class="verinfo">(PECL mongo &gt;=1.0.2)</p><p class="refpurpose"><span class="refname">MongoCollection::__get</span> &mdash; <span class="dc-title">Gets a collection</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-mongocollection.get-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>MongoCollection::__get</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>): <span class="type"><a href="class.mongocollection.html" class="type MongoCollection">MongoCollection</a></span></div>

  <p class="para rdfs-comment">
   A concise syntax for getting a collection with a dot-separated name.  If a
   collection name contains strange characters, you may have to use
   <span class="function"><a href="mongodb.selectcollection.html" class="function">MongoDB::selectCollection()</a></span> instead.
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$mongo&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;the&nbsp;following&nbsp;two&nbsp;lines&nbsp;are&nbsp;equivalent<br /></span><span style="color: #0000BB">$collection&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mongo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">selectDB</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">selectCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">"bar.baz"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$collection&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mongo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">foo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">baz</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-mongocollection.get-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt>

      <code class="parameter">name</code>
     </dt>

     <dd>

      <p class="para">
       The next string in the collection name.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-mongocollection.get-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the collection.
  </p>
 </div>

</div></div></div></body></html>